<?php
/**
 * Core_Data_Currentmoduledata
 * current module data
 * @author Adrian Stolarski
 */
class Core_Data_Currentmoduledata implements Core_Data_Mainable, 
        Core_Data_Preparable{
    
    /**
     *
     * @var type $database
     * database handler
     */
    public $database;
    /**
     *
     * @var type $database_query
     * database query handler
     */
    public $database_query;
    
    /**
     * constructor()
     */
    public function __construct() {
        $this->database = new Core_Driver_MysqlImproved;
    }
    
    /**
     * main()
     * return current module data
     * 
     * @param array $variables
     * @return type $module_data
     */
    public function main(array $variables = null) {
        $this->database->connect();
        foreach($variables as $key => $value){
            $variables[$key] = $this->database->escape($value);
        }
        $this->prepare_query($variables);
        $this->database->prepare($this->database_query);
        $this->database->query();
        $module_data = $this->database->fetch('array');
        //var_dump($module_data);
        //die();
        return $module_data;
    }
    
    /**
     * prepare_query()
     * prepare database query
     * 
     * @param array $variables
     */
    public function prepare_query(array $variables = null) {
        $this->database_query = "SELECT * FROM page_module WHERE id=".$variables['main_category_module_id'].";";
    }

}
